import config from '../config/config';
import request from '../utils/request';

let service = {};
//免费拿商品列表
service.collagegoodslist = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.collagegoodslist;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//从分享进入助力页面
service.collagefriendcheck = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.collagefriendcheck;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//点击给好友助力
service.collagefriendadd = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.collagefriendadd;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    }
  });
}

//我的免费拿订单列表
service.collageorderlist = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.collageorderlist;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//免费拿轮播
service.collage = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.collage;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//发起拼团订单
service.initiatecollageorder = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.initiatecollageorder;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    }
  });
}

//2.9特惠商品列表
service.getcheap_goods = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getcheap_goods;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//2.12.0买家今日热销商品
service.customerRecommend = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.customerRecommend;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

module.exports = service;